package com.zh.note.huawei.onehundred.路灯照明;

/**
 * @Author: zhanghuan
 * @date: 2023/9/2 20:18
 * @description: create it
 */

import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        try (Scanner s = new Scanner(System.in)) {
            // int n = s.nextInt();
            // int[] arr = new int[n];
            // for (int i = 0; i < n; ++i) {
            //     arr[i] = s.nextInt();
            // }
            int[] arr = {50, 70, 20, 70};
            boolean[] bools = new boolean[(arr.length - 1) * 100];

            IntStream.range(0, arr.length).forEach(i -> {
                int pos = i * 100;
                int left = Math.max(pos - arr[i], 0);
                int right = Math.min(pos + arr[i], bools.length);

                IntStream.range(left, right).forEach(k -> bools[k] = true);
            });
            //统计bools数组中false个数
            long count = IntStream.range(0, bools.length).filter(i -> !bools[i]).count();
            System.out.println(count);
        }
    }
}

